package com.springcloud.yishop.service;

import com.yishop.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;
//降级
@Component
public class DeptClientServiceFallBackFactory  implements FallbackFactory {
    @Override
    public DeptClientService create(Throwable throwable) {
        return new DeptClientService() {
            @Override
            public Dept queryById(Long id) {
                Dept dept = new Dept();
                dept.setDeptno(id);
                dept.setDname("id=>"+id+"没有对应的信息,客户端提供了降级,这个服务现在己经被关闭");
                dept.setDb_source("no this database in Mysql");
                return  dept;
            }

            @Override
            public List<Dept> query() {
                return null;
            }

            @Override
            public boolean addDept(Dept dept) {
                return false;
            }
        };
    }
}
